import VueRouter from "vue-router";

import {
    fake
} from "../assets/fake";
import {
    app
} from "../global/global";

const router = new VueRouter({
    routes: [{
            name: '/',
            path: '/',
            component: () => import('../components/recommend/Recommend.vue'),
        },
        {
            name: 'Recommend',
            path: '/Recommend',
            component: () => import('../components/recommend/Recommend.vue'),
        },
        {
            name: 'Article',
            path: '/Article',
            component: () => import('../components/mode/ArticleMode.vue'),
        },
        {
            name: 'Focus',
            path: '/Focus',
            component: () => import('../components/focus/Focus.vue'),
            beforeEnter: (to, from, next) => {
                if (fake.self === null) {
                    app.$alert("登陆后才能查看自己的关注哦", "提示", {
                        confirmButtonText: "确定",
                        type: "warning",
                    })
                    router.push({
                        name: '/',
                    })
                } else {
                    next();
                }
            },
        },
        {
            name: 'User',
            path: '/User',
            component: () => import("../components/user/User.vue"),
            children: [{
                    name: 'UpdateSelf',
                    path: 'UpdateSelf',
                    component: () => import("../components/updateSelf/UpdateSelf.vue"),
                    beforeEnter: (to, from, next) => {
                        if (fake.self === null) {
                            app.$alert("登陆后才能查看哦", "提示", {
                                confirmButtonText: "确定",
                                type: "warning",
                            })
                            router.push({
                                name: '/',
                            })
                        } else {
                            next();
                        }
                    },
                },
                {
                    name: 'UserInfo',
                    path: 'UserInfo',
                    component: () => import("../components/mode/UserInfoMode.vue"),
                    beforeEnter: (to, from, next) => {
                        if (fake.self === null) {
                            app.$alert("登陆后才能查看哦", "提示", {
                                confirmButtonText: "确定",
                                type: "warning",
                            })
                            router.push({
                                name: '/',
                            })
                        } else {
                            next();
                        }
                    },
                },
                {
                    name: 'LineUserList',
                    path: 'LineUserList',
                    component: () => import("../components/lineUserList/LineUserList.vue"),
                    beforeEnter: (to, from, next) => {
                        if (fake.self === null) {
                            app.$alert("登陆后才能查看哦", "提示", {
                                confirmButtonText: "确定",
                                type: "warning",
                            })
                            router.push({
                                name: '/',
                            })
                        } else {
                            next();
                        }
                    },
                },
            ],
            beforeEnter: (to, from, next) => {
                if (fake.self === null) {
                    app.$alert("登陆后才能查看哦", "提示", {
                        confirmButtonText: "确定",
                        type: "warning",
                    })
                    router.push({
                        name: '/',
                    })
                } else {
                    next();
                }
            },
        },
        {
            name: 'Message',
            path: '/Message',
            component: () => import("../components/message/MyMessage.vue"),
            beforeEnter: (to, from, next) => {
                if (fake.self === null) {
                    app.$alert("登陆后才能查看消息哦", "提示", {
                        confirmButtonText: "确定",
                        type: "warning",
                    })
                    router.push({
                        name: '/',
                    })
                } else {
                    next();
                }
            }
        },
    ]
})

export default router;